package com.zhouchao.code.controller;

import com.zhouchao.code.common.Result;
import com.zhouchao.code.service.ICodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: zhouchao
 * @Date: 2021/10/16 20:19
 * @Description:
 */
@RestController
@RequestMapping("api/code")
public class CodeController {

    @Autowired
    private ICodeService codeService;

    @GetMapping("create/{email}")
    public Result<Boolean> createCode(@PathVariable String email) {
        Result<Boolean> result = codeService.createCode(email);
        return result;
    }

    @GetMapping("validate/{email}/{code}")
    public Result<Integer> validateCode(@PathVariable String email, @PathVariable String code) {
        Result<Integer> result = codeService.validateCode(email, code);
        return result;
    }

}
